var minWindow = function (s, t) {
  let need = {},
    window = {};
  for (let c of t) {
    if (!need[c]) need[c] = 1;
    else need[c]++;
  }
  let left = 0,
    right = 0;
  let valid = 0,
    len = Object.keys(need).length;
  let minLen = s.length + 1,
    minStr = '';
  while (right < s.length) {
    const d = s[right];
    right++;
    if (!window[d]) window[d] = 1;
    else window[d]++;
    if (need[d] && need[d] === window[d]) {
      valid++;
    }
    console.log('left - right', left, right);
    while (valid === len) {
      if (right - left < minLen) {
        minLen = right - left;
        minStr = s.slice(left, right);
      }
      console.lo;
      let c = s[left];
      left++;
      window[c]--;
      if (need[c] && window[c] < need[c]) {
        valid--;
      }
    }
  }
  return minStr;
};
